package com.example.springdemo.domain.reqVo;

import com.example.springdemo.enums.Sex;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;

/**
 * ReqAddUser
 *
 * @author wenguang
 * @date 2020/12/11 15:58
 */
@Data
@ApiModel(description = "添加用户vo")
public class ReqAddUser implements Serializable {

    private static final long serialVersionUID = -1848603272045379979L;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名", required = true)
    @NotBlank(message = "【用户名】不能为空")
    private String userName;

    /**
     * 登陆密码
     */
    @ApiModelProperty(value = "登陆密码", required = true)
    @NotBlank(message = "【密码】不能为空")
    @Pattern(regexp = "^\\d{6,}$", message = "【密码】不小于6位")
    private String password;

    /**
     * 性别(0-女，1-男，2-保密)
     */
    @ApiModelProperty(value = "性别(0-女，1-男，2-保密)")
    @NotNull(message = "【性别】不能为空")
    private Sex sex;

    /**
     * 生日
     */
    @ApiModelProperty(value = "生日", required = true)
    @NotNull(message = "【生日】不能为空")
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate birthday;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱", required = true)
    @Email(regexp = "^\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}$", message = "【邮箱】错误")
    private String email;

    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号", required = true)
    @Pattern(regexp = "^(13\\d|14[579]|15[^4\\D]|17[^49\\D]|18\\d)\\d{8}$", message = "【手机号】错误")
    private String mobile;

    /**
     * 位置，省
     */
    @ApiModelProperty(value = "位置，省", required = true)
    @NotBlank(message = "【位置，省】不能为空")
    private String province;

    /**
     * 位置，市
     */
    @ApiModelProperty(value = "位置，市", required = true)
    @NotBlank(message = "【位置，市】不能为空")
    private String city;

    /**
     * 位置，县
     */
    @ApiModelProperty(value = "位置，县", required = true)
    @NotBlank(message = "【位置，县】不能为空")
    private String district;

}
